package org.lee.resbundle;

import java.io.IOException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;

/**
 * Demo
 *
 * @author dralee
 * @date 2021-12-28 15:00:54
 **/
public class Demo {
    public static void main(String[] args) {
        String path = Demo.class.getClassLoader().getResource("words_en.properties").getPath();
        try(DirectoryStream<Path> files = Files.newDirectoryStream(Paths.get(path.substring(1)).getParent())){
            files.forEach(f->{
                if(Files.isDirectory(f)){
                    return;
                }
                if(!f.getFileName().toString().endsWith(".properties")){
                    return;
                }
                try {
                    System.out.printf("%s:\r\n",f.getFileName());
                    List<String> lines = Files.readAllLines(f, StandardCharsets.UTF_8);
                    System.out.println(String.join("\r\n", lines));
                    System.out.println();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            });
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
